﻿CREATE PROCEDURE [dbo].[proc_Finance_Subject_GetListNew]
	(
		@CateOneId int,
		@CateTwoId int
	)
AS
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY Id)AS Row,
	Id,
	SId,
	ParentOldId,
	CateOneId,
	CateTwoId,
	Title,
	Description,
	Sort,
	CreateDate,
	Isnull((Select Title From Finance_Subject_Parent Where Id=Finance_Subject.CateOneId),'---') As CateOne,
	Isnull((Select Title From Finance_Subject_Parent Where Id=Finance_Subject.CateTwoId),'---') As CateTwo,
	Isnull((Select Title From Finance_Subject_ParentOld Where Id=Finance_Subject.ParentOldId),'---') As ParentOldName
	From Finance_Subject Where (@CateOneId=0 Or CateOneId=@CateOneId ) And (@CateTwoId=0 Or CateTwoId=@CateTwoId)
	
	)
	Select * From list
	RETURN
